<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class UserController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
        $this->middleware('auth');
    }

    /**
     * 注销（同时注销中心版）
     */
    public function logout(Request $request)
    {
        $url = request('url', route('homes'));
        $user = Auth::user();
        Auth::logout();
        $uac = $this->getUac();
        $uac->callRpcMethod('user.UserLogout', [$user->user_id]);
        return redirect($url);
    }

    /**
     * 中心平台注销
     */
    public function profile(Request $request)
    {
        $user = Auth::user();
        $group = $user->group;
//        var_dump($group->getPath());exit;
        $data = [
            'user' => $user,
            'group_path' => implode(' > ', $group->getPath()),
        ];
        return view('users.profile', $data);
    }
}
